package com.example.admin.service;


import com.example.admin.common.Result;
import com.example.admin.entity.ElderArchive;
import com.example.admin.mapper.ElderArchiveMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ElderArchiveService {



    @Autowired
    private ElderArchiveMapper elderArchiveMapper;

    public List<ElderArchive> selectElderArchivePage() {

       List<ElderArchive> elderArchiveList=elderArchiveMapper.selectElderArchivePage();
       return elderArchiveList;
    }

    public Result addElderArchive(ElderArchive elderArchive) {
      int count=  elderArchiveMapper.addElderArchive(elderArchive);
      if(count==0)
      {
          return Result.error("400","新增失败");
      }
      return Result.success("新增成功");
    }

    public Result editeElderArchive(ElderArchive elderArchive) {

        int count=elderArchiveMapper.editeElderArchive(elderArchive);
        if(count==0)
        {
            return Result.error("400","修改失败");
        }
        return Result.success("修改成功");
    }

    public Result deleteElderArchiveById(Integer id) {

        int count=elderArchiveMapper.deleteElderArchiveById(id);
        if(count==0)
        {
            return Result.error("400","删除失败");
        }
        return Result.success("删除成功");
    }

    public List<ElderArchive> selectElderArchiveByName(String name) {

       List<ElderArchive> elderArchiveList= elderArchiveMapper.selectElderArchiveByName(name);
       return elderArchiveList;
    }
}
